const Koa = require('koa')
const cors = require('koa2-cors')

const bodyParser = require('koa-bodyparser')

const controller = require('./controller')

const app = new Koa()

// log request URL:
app.use(async(ctx, next) => {
  console.log(`Process ${ctx.request.method} ${ctx.request.url}...`)
  await next()
})

// parse request body:
app.use(bodyParser())
app.use(cors())
// add controllers:
app.use(controller())

app.listen(3000)
console.log('app started at port 3000...')
